package com.hackordie.commons.hardware.components;

import com.hackordie.constants.EComponentsType;

public class Processor extends AComponent {

    private int speedForCore;
    private int calculatedSpeedForCore;  /** cada core tendra su velocidad individual, con una penalizacion a la speed   */
    private int cores;
    private int totalCapacity;  // capacidad total: calculatedSpeedForCore * cores
    

    public Processor(String componentName, int energyToTurOn,
            int speedForCore, int cores, int levelSkill, int prize) {
        super(componentName, EComponentsType.Processor, energyToTurOn, prize);

        this.cores = cores;
        this.speedForCore = speedForCore;
        
        if (cores > 1) {
            this.calculatedSpeedForCore = speedForCore - ( (cores % 100) * (100 - levelSkill)); //TODO revisar formulas
        } else {
            this.calculatedSpeedForCore = totalCapacity;
        }
        
        totalCapacity = calculatedSpeedForCore * cores;
    }


    // getters and setters
    public int getCalculatedSpeedForCore() {
        return calculatedSpeedForCore;
    }

    public void setCalculatedSpeedForCore(int calculatedSpeedForCore) {
        this.calculatedSpeedForCore = calculatedSpeedForCore;
    }

    public int getCores() {
        return cores;
    }

    public void setCores(int cores) {
        this.cores = cores;
    }

    public int getTotalCapacity() {
        return totalCapacity;
    }

    public void setTotalCapacity(int totalCapacity) {
        this.totalCapacity = totalCapacity;
    }

    public int getSpeedForCore() {
        return speedForCore;
    }

    public void setSpeedForCore(int speedForCore) {
        this.speedForCore = speedForCore;
    }   
    
    @Override
    public String toString() {        
        
        return super.toString() + "-" + 
               speedForCore + "-" +
               calculatedSpeedForCore + "-" +
               cores + "-" +
               totalCapacity;
    }
 }
